function submit(){
	var ID = document.getElementById("ID").value;
	var name  = document.getElementById("name").value;
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("POST", "/student/addStudent", true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("list").innerHTML=xmlhttp.responseText;
    	}
    	if(xmlhttp.status==404){
    		window.alert("404!");
    	}
  	};
	xmlhttp.send(JSON.stringify({'id':ID,'name':name}));
}

function query(){
	var xmlhttp = new XMLHttpRequest();

	var id = document.getElementById("ID").value;

	xmlhttp.open("GET", "/student/"+id, true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("list").innerHTML=xmlhttp.responseText;
    	}
    	if(xmlhttp.status==404){
    		window.alert("404!");
    	}
  	}
	xmlhttp.send();
}

function listAll() {
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", "/student/", true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("list").innerHTML=xmlhttp.responseText;
    	}
    	if(xmlhttp.status==404){
    		window.alert("404!");
    	}
  	}
	xmlhttp.send();
}

function deleteStudent() {
	var xmlhttp = new XMLHttpRequest();
	var id = document.getElementById("ID").value;

	xmlhttp.open("GET", "/student/deleteStudent/"+id, true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("list").innerHTML=xmlhttp.responseText;
    	}
    	if(xmlhttp.status==404){
    		window.alert("404!");
    	}
  	}
	xmlhttp.send();
}

function sendRequest(url, data, requestType) {
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open(requestType, url, true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
    		document.getElementById("list").innerHTML=xmlhttp.responseText;
    	}
    	if(xmlhttp.status==404){
    		window.alert("404!");
    	}
  	}
	xmlhttp.send(data);
}